#include <iostream>
#include<algorithm>
using namespace std;

int n, k;
int robot[100050];

bool check(int len)
{
  int sweep = 0;
  for(int i=1; i<=k; i++)
  {
    if(robot[i] - len <= sweep)
    {
      if(robot[i] <= sweep) 
        sweep = len + robot[i] - 1;
      else  
        sweep += len;
    }
    else
      return false;
  }
  return sweep >= n;
}

int main()
{

  cin >> n >> k;
  for(int i=1; i<=k; i++)
  {
    cin >> robot[i];
  }
  sort(robot+1, robot+1+k);
  int L = 0, R =n, mid, ans;
  while(L <= R)
  {
    mid = L + (R - L) / 2;
    if(check(mid))
    {
      R = mid - 1;
      ans = mid;
    }
    else
    {
      L = mid + 1;
    }
  }
cout << 2 * (ans - 1) << endl;
  return 0;
}